Skip to content

Implement CLI command atomcommit plan to analyze git working tree and produce atomic commit plan#3

Merged
rogerchappel merged 7 commits into
mainfrom
agent/implement-cli-command-atomcommit-plan-to-analyze-git-working-tree-and-pr
Apr 29, 2026
Merged

Implement CLI command atomcommit plan to analyze git working tree and produce atomic commit plan#3
rogerchappel merged 7 commits into
mainfrom
agent/implement-cli-command-atomcommit-plan-to-analyze-git-working-tree-and-pr

Conversation

@rogerchappel

Copy link
Copy Markdown
Owner

Summary

This PR hardens the existing atomcommit plan CLI command with comprehensive tests, fixture repos, and documentation. The core functionality was already implemented in f90d5ba (Add deterministic plan command). This PR focuses on verification, determinism, and reviewable documentation.

Changes

1. Fixture Repositories

  • Added fixtures/setup-mixed-changes.sh — script to create deterministic test repos
  • Added fixtures/mixed-changes-repo — generated fixture with 9 file changes across 4 groups:
    • Modified source files
    • New and modified test files
    • Documentation changes
    • CI/CD configuration changes
    • Renamed files
    • Deleted binary files
  • Added .gitignore to exclude generated fixture repos

2. Test Suite Enhancements (6 tests total)

Existing tests (3):

  • ✅ Parses git name-status metadata including renames
  • ✅ Builds deterministic grouped plan and markdown
  • ✅ CLI reads local git diff without mutating the working tree

New tests (3):

  • ✅ Fixture repo validation — verifies CLI against repo with mixed changes, checks all groups and risk flags
  • ✅ Commit message validation — asserts suggested messages are meaningful and follow conventions
  • ✅ Snapshot test — verifies exact structure, file counts, and risk flags match expected output

All tests pass and output is deterministic across multiple runs.

3. Documentation

README.md:

  • Added overview section with key features
  • Full usage examples with sample output
  • Grouping logic table (documenting how files are classified)
  • Risk flag definitions and trigger conditions
  • Fixture repository documentation

docs/README.md:

  • Added decision log documenting grouping logic rationale
  • Risk flag trigger conditions and review rationale
  • Future enhancement ideas

4. Package Configuration

  • Updated package.json test script to only run test/**/*.test.js (exclude fixtures from test runner)

Verification

Test Results

✔ parses git name-status metadata including renames
✔ builds deterministic grouped plan and markdown
✔ cli reads local git diff without mutating the working tree
✔ fixture repo with mixed changes produces expected plan
✔ suggests commit messages based on grouped files
✔ snapshot: mixed changes produce consistent plan

6 tests, 6 pass, 0 fail
npm test
bash scripts/validate.sh

Both pass all checks.

Manual Testing

# Test against fixture repo
cd fixtures/mixed-changes-repo
../../src/index.js          # Markdown output
../../src/index.js --json   # JSON output

# Test determinism (run twice, compare)
../../src/index.js > /tmp/run1.md
../../src/index.js > /tmp/run2.md
diff /tmp/run1.md /tmp/run2.md   # No differences

Design Decisions

Grouping Logic

Files are grouped based on path and extension:

Group Pattern
CI and repository automation .github/*
Documentation docs/*, *.md files
Tests test/*, *.test.js
Source code src/*, *.js source files
Root files Top-level files not matching above

Rationale: Co-locates related changes for focused review (docs together, tests together, etc.).

Risk Flags

Flag Trigger
deletion Git status D (file deleted)
rename Git status R (file renamed/moved)
binary-file No text stats available
large-change Additions + deletions ≥ 400 lines

Rationale: Flags highlight changes requiring extra review attention.

Commits

  1. test: add fixture repo for mixed changes with snapshot test
  2. test: add snapshot and fixture tests for deterministic plan output
  3. docs: expand README with usage examples, grouping logic, and risk flags

All commits are focused and atomic.

Human Review Needed

  • ✅ Approve grouping logic and risk flag criteria (documented in README and docs/README.md)
  • ✅ Validate commit message suggestion quality (documented in README examples)

Links

  • Issue: N/A (implementing task brief)
  • Branch: agent/implement-cli-command-atomcommit-plan-to-analyze-git-working-tree-and-pr

Add fixtures/ directory with:

- setup-mixed-changes.sh: script to create deterministic test repo

- mixed-changes-repo: generated fixture with 9 file changes across 4 groups

- .gitignore: exclude generated fixture repos

The fixture exercises all grouping logic, risk flagging, and commit message suggestion including:

- Modified source files

- New and modified test files

- Documentation changes and additions

- CI/CD configuration changes

- Renamed files

- Deleted binary files

Tests verify deterministic output across multiple runs and assert expected structure.
Add 3 new tests:

- Fixture repo validation: verifies CLI against repo with mixed changes, checks all groups and risk flags

- Commit message validation: asserts suggested messages are meaningful

- Snapshot test: verifies exact structure, file counts, and risk flags match expected output

Update package.json test script to only run test/ files (exclude fixtures).

All 6 tests pass (3 existing + 3 new).
Add comprehensive documentation:

README.md:

- Overview section with key features

- Full usage examples with sample output

- Grouping logic table

- Risk flag definitions

- Fixture repository documentation

docs/README.md:

- Added decision log documenting grouping logic rationale

- Risk flag trigger conditions and review rationale

- Future enhancement ideas

Provides sufficient documentation for human approval of logic and criteria.
@rogerchappel rogerchappel merged commit 9a40770 into main Apr 29, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant